<%@ page import="jxl.Workbook" %>
<%@ page import="jxl.Sheet" %>
<%@ page import="jxl.Cell" %>
<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<%
    //创建部门 DEPT_REGISTER =9
    hospital = 1113;
    //先删除部门
    QBuilder.db("basedb").execHQL("delete from Dept where hospital = " + hospital + "  and type = " + DEPT_ALL);
    //然后读取excl
    Workbook book = null;
    try {
        book = Workbook.getWorkbook(new File(request.getServletContext().getRealPath("/") + "patient/1113/dept/dept.xls"));
        Sheet sheet = book.getSheet(0);
        int rows=sheet.getRows();
        int columns=sheet.getColumns();
        List deptList = new ArrayList();//存储集合
       for(int i = 0 ; i < rows ; i++ ){
           Cell cellName = sheet.getCell(0, i);
           Cell cellContent = sheet.getCell(1, i);
           if("".equals(cellName)){
              continue;
           }
           Dept dept = new Dept();
           dept.setDeptName(cellName.getContents());
           String summary = cellContent.getContents().length()>100 ?cellContent.getContents().substring(0,100) : cellContent.getContents();
           dept.setSummary(summary);
           dept.setContent(cellContent.getContents());
           dept.setStatus(1);
           dept.setHospital(hospital);
           dept.setDeptOrder(i+1);
           dept.setHospitalOrder(i+1);
           dept.setType(DEPT_ALL);
           dept.setBranch("1");
           dept.setBranchName("锡山人民医院");
           dept.setDeptId(Tools.getMD5(cellName.getContents()));

           deptList.add(dept);
       }

        DBTools.db("basedb").addItem(deptList);
        out.println("执行完毕");
    } catch (Exception e) {
      e.printStackTrace();
    }
%>
